home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / nbdetect.zip / NBDETECT.C < prev    next >
Text File  |  1992-03-05  |  3KB  |  119 lines

  1. /*****************************************************************************
  2.  nbdetect.c
  3.  
  4.  Developed November 1991 by Larry Reeve
  5.  
  6.  A TurboC program to detect the presence of NetBIOS.
  7. ******************************************************************************/
  8. #include <dos.h>
  9. #include <stdio.h>
  10.  
  11. #define USGC                unsigned char
  12. #define DOS_INT_21          0x21
  13. #define DOS_INT_2A          0x2A
  14. #define DOS_INT_2F          0x2F
  15.  
  16. #define PC_LAN_PGM_CHECK    0xB800
  17. #define DOS_FETCH_VERSION   0x30
  18. #define GET_MACHINE_NAME    0x5E00
  19.  
  20. #define REDIRECTOR_FLAG     0x0008
  21. #define RECEIVER_FLAG       0x0080
  22. #define MESSENGER_FLAG      0x0004
  23. #define SERVER_FLAG         0x0040
  24.  
  25. int  CheckDosVersion(void);
  26. void CheckForIBMLanProgram(void);
  27. void GetMachineName(void);
  28.  
  29. void main (void)
  30.  
  31. {
  32.     printf("NBDETECT 1.0 - NetBIOS & IBM PC LAN PROGRAM Detector");
  33.  
  34.     if (CheckDosVersion() == 0)
  35.       CheckForIBMLanProgram();
  36.  
  37.     printf("\n");
  38. }
  39.  
  40. int CheckDosVersion()
  41. {
  42.     union REGS InRegs,OutRegs;
  43.     InRegs.h.ah = DOS_FETCH_VERSION;
  44.     int86(DOS_INT_21,&InRegs,&OutRegs);
  45.     printf("\n -DOS version is %u.%u",OutRegs.h.al,OutRegs.h.ah);
  46.  
  47.     if (OutRegs.h.al < 3)
  48.       return (-1);
  49.  
  50.     if (OutRegs.h.al == 3)
  51.       if (OutRegs.h.ah < 10)
  52.         return (-1);
  53.  
  54.     InRegs.h.ah = 0;
  55.     int86(DOS_INT_2A,&InRegs,&OutRegs);
  56.     if (OutRegs.h.ah != 0)
  57.       printf("\n -The INT2A NetBIOS interface is available.");
  58.     else
  59.       printf("\n -The INT2A NetBIOS interface is not available.");
  60.  
  61.     return (0);
  62. }
  63.  
  64. void CheckForIBMLanProgram()
  65. {
  66.     USGC    temp;
  67.     union   REGS    InRegs,OutRegs;
  68.  
  69.     InRegs.x.ax = PC_LAN_PGM_CHECK;
  70.     int86(DOS_INT_2F,&InRegs,&OutRegs);
  71.     if (OutRegs.h.al == 0)
  72.     {
  73.         printf("\n -The IBM PC Lan program is not installed.");
  74.         return;
  75.     }
  76.     printf("\n -The IBM PC Lan program is installed.");
  77.     printf("\n -This station is operating as a ");
  78.     temp = OutRegs.h.bl & (REDIRECTOR_FLAG | RECEIVER_FLAG |
  79.                            MESSENGER_FLAG | SERVER_FLAG);
  80.  
  81.     if (SERVER_FLAG & temp)
  82.       printf("server.");
  83.     else if (MESSENGER_FLAG & temp)
  84.       printf("messenger.");
  85.     else if (RECEIVER_FLAG & temp)
  86.       printf("receiver.");
  87.     else if (REDIRECTOR_FLAG & temp)
  88.       printf("redirector.");
  89.     else
  90.     {
  91.         printf("UNKNOWN CONFIGURATION! \n");
  92.         return;
  93.     }
  94.     GetMachineName();
  95. }
  96.  
  97.  
  98. void GetMachineName()
  99. {
  100.     struct  SREGS   SegRegs;
  101.     union   REGS    InRegs,OutRegs;
  102.     char    Buffer[16];
  103.     char    *BufferPtr = Buffer;
  104.  
  105.     InRegs.x.ax = GET_MACHINE_NAME;
  106.     SegRegs.ds  = FP_SEG(BufferPtr);
  107.     InRegs.x.dx = FP_OFF(BufferPtr);
  108.     int86x(DOS_INT_21,&InRegs,&OutRegs,&SegRegs);
  109.  
  110.     if (OutRegs.h.ch != 0)
  111.     {
  112.         printf("\n -The machine name   is '%s'",Buffer);
  113.         printf("\n -The machine number is %u.",OutRegs.h.cl);
  114.     }
  115.     else
  116.         printf("\n -The machine name is not defined.");
  117.  
  118. }
  119.